package com.fy.fyspace.model.enums.user;

import lombok.Getter;

/**
 * 用户角色枚举
 */
@Getter
public enum UserRoleEnum {
    ADMIN("admin", "管理员"),
    USER("user", "普通用户");

    private final String type;
    private final String desc;

    UserRoleEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static UserRoleEnum getEnumByType(String type) {
        if (type == null) {
            return USER;
        }
        for (UserRoleEnum roleEnum : UserRoleEnum.values()) {
            if (roleEnum.getType().equals(type)) {
                return roleEnum;
            }
        }
        return USER;
    }
}
